package Thread;

public class ThreadDemo9 {
    public static void main(String[] args) throws InterruptedException {
        Thread thread1 = new Thread(() -> {
            for(int i = 0; i < 3; i++) {
                System.out.println("子线程1正在工作中...");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });

        Thread thread2 = new Thread(() -> {
            for(int i = 0; i < 3; i++) {
                System.out.println("子线程2正在工作中...");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });

        Thread thread3 = new Thread(() -> {
            for(int i = 0; i < 3; i++) {
                System.out.println("子线程3正在工作中...");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });

        // 这里是重点！！
        thread1.start();

        thread2.start();
        thread1.join();

        thread3.start();

        System.out.println("这是主线程，等待子线程结束后，该日志才能打印");
    }
}
